package com.fanyouzhao.ssm251.util;

import java.io.*;
import java.util.Date;

/**
 * @author: fanyouzhao
 * @date: 8:58 2021/6/4
 */
public class LogToFile {
    public static boolean log(String logContent){
        try {
            String filePath = "";
            File file = new File(filePath);
            if (!file.exists()) {
                file.createNewFile();
                file = new File(filePath);
            }
            FileWriter fw = new FileWriter(file, true);
            BufferedWriter bw = new BufferedWriter(fw);
            PrintWriter pw = new PrintWriter(bw);
            Date date = new Date();
            System.out.println(date+":"+logContent);
            pw.println(date+":"+logContent);
            pw.close();
            bw.close();
            fw.close();
            return true;
        } catch (IOException e) {
            return false;
        }
    }
}
